#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(int argc1,char **argv1,QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    this->argc=argc1;
    this->argv=argv1;
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_pushButton_clicked()
{
    QLibrary* mainFunDll = new QLibrary("E:/C++_code/dll/dllFunc/build-untitled-Desktop_Qt_5_15_2_MinGW_32_bit-Release/release/untitled.dll");
    if (mainFunDll->load()) {
        getObj obj = (getObj)mainFunDll->resolve("getDllObj");
        //Untitled* mF = obj();
        //mF->printMsg(QStringLiteral("这是一个DLL调用程序"));
        //mF->VopenWindow(argc,argv);
        //qDebug()<<mF->add(4, 7);

        //dllText dText = (dllText)mainFunDll->resolve("text");
        //qDebug() << QString::fromLocal8Bit(dText());

        dllPrintInt dPrintInt = (dllPrintInt)mainFunDll->resolve("printInt");
        qDebug() << dPrintInt();
        openwinfunc dpenwin = (openwinfunc)mainFunDll->resolve("openwin");
        dpenwin(this->argc,this->argv);

    } else {
        QMessageBox* msgBox = new QMessageBox;
        msgBox->setText(QStringLiteral("动态库加载失败！"));
        msgBox->setWindowTitle(QStringLiteral("信息框"));
        msgBox->show();
    }

}

